package payroll.trans;

import java.util.Map;

import payroll.Employee;
import payroll.Paycheck;
import payroll.PayrollDatabase;
import payroll.Transaction;

//import payroll.Employee;
//import payroll.PayrollDatabase;
//import payroll.Transaction;
import java.util.LinkedHashMap;
//import payroll.Paycheck;

public class PaydayTransaction implements Transaction {
    private Map<Integer, Paycheck> paychecks = new LinkedHashMap<>();

    
    @Override
    public void execute(){
        //为每个雇员薪金
        for (Employee e : PayrollDatabase.listAllEmployees()){
            //创建一个Paycheck
            Paycheck paycheck = new Paycheck();
            //计算工资并填写支付方式到Paycheck
            e.pay(paycheck);//根据计算工资的方式及，支付方式，填写paycheck
            //保存Paycheck
            paychecks.put(e.getEmpId(), paycheck);
        }
    }

    public Paycheck getPaycheckOf(int empId) {
        return paychecks.get(empId);
    }

}
